Imports GrapeCity.Win.CalendarGrid
Imports InputManCell = GrapeCity.Win.CalendarGrid.InputMan
Imports CalendarGridInputMan = GrapeCity.Win.CalendarGrid.Editors
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim today As DateTime = DateTime.Today
Dim GcTimeSpanCellType As New InputManCell.CalendarGcTimeSpanCellType()
' 最大値と最小値を設定します。
GcTimeSpanCellType.MaxValue = TimeSpan.Parse("1.00:00:00")
GcTimeSpanCellType.MinValue = TimeSpan.Parse("00:00:00")
' 範囲外の場合に値をどのように制御するかを設定します。
GcTimeSpanCellType.MaxMinBehavior = InputMan.MaxMinBehavior.CancelInput
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = GcTimeSpanCellType
GcCalendarGrid1.ScrollIntoView(today)
AddHandler GcCalendarGrid1.EditingControlShowing, AddressOf GcCalendarGrid1_EditingControlShowing
End Sub
Private Sub GcCalendarGrid1_EditingControlShowing(sender As Object, e As CalendarEditingControlShowingEventArgs)
If TypeOf e.Control Is CalendarGridInputMan.GcTimeSpan Then
Dim editor As CalendarGridInputMan.GcTimeSpan = DirectCast(e.Control, CalendarGridInputMan.GcTimeSpan)
RemoveHandler editor.InvalidInput, AddressOf editor_InvalidInput
AddHandler editor.InvalidInput, AddressOf editor_InvalidInput
End If
End Sub
Private Sub editor_InvalidInput(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim InvalidInputEventArgs As CalendarGridInputMan.InvalidInputEventArgs = TryCast(e, CalendarGridInputMan.InvalidInputEventArgs)
If InvalidInputEventArgs Is Nothing Then
Exit Sub
End If
' 値が範囲外の場合には、メッセージを表示します。
If InvalidInputEventArgs.ValueOutOfRange Then
MessageBox.Show("範囲外の値です。")
End If
End Sub
using GrapeCity.Win.CalendarGrid;
using InputManCell = GrapeCity.Win.CalendarGrid.InputMan;
using CalendarGridInputMan = GrapeCity.Win.CalendarGrid.Editors;
private void Form1_Load(object sender, EventArgs e)
{
var today = DateTime.Today;
var gcTimeSpanCellType = new InputManCell.CalendarGcTimeSpanCellType();
// 最大値と最小値を設定します。
gcTimeSpanCellType.MaxValue = TimeSpan.Parse("1.00:00:00");
gcTimeSpanCellType.MinValue = TimeSpan.Parse("00:00:00");
// 範囲外の場合に値をどのように制御するかを設定します。
gcTimeSpanCellType.MaxMinBehavior = InputManCell.MaxMinBehavior.CancelInput;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = gcTimeSpanCellType;
gcCalendarGrid1.ScrollIntoView(today);
gcCalendarGrid1.EditingControlShowing += gcCalendarGrid1_EditingControlShowing;
}
private void gcCalendarGrid1_EditingControlShowing(object sender, CalendarEditingControlShowingEventArgs e)
{
if (e.Control is CalendarGridInputMan.GcTimeSpan)
{
CalendarGridInputMan.GcTimeSpan editor = (CalendarGridInputMan.GcTimeSpan)e.Control;
editor.InvalidInput -= editor_InvalidInput;
editor.InvalidInput += editor_InvalidInput;
}
}
private void editor_InvalidInput(object sender, EventArgs e)
{
CalendarGridInputMan.InvalidInputEventArgs invalidInputEventArgs = e as CalendarGridInputMan.InvalidInputEventArgs;
if (invalidInputEventArgs == null)
{
return;
}
// 値が範囲外の場合には、メッセージを表示します。
if (invalidInputEventArgs.ValueOutOfRange)
{
MessageBox.Show("範囲外の値です。");
}
}